const data = require('./mock')
const BodyParser = require('body-parser')

module.exports = app => {
    app.use(BodyParser.json())

    app.post('/api/getList', (req, res) => {
        const { trademark, downPrice } = req.body
        
        let newList = data

        if (trademark) {
            newList = newList.filter((item) => item.trademark === trademark)
        }

        if (downPrice) {
            newList = newList.filter(item => item.downPrice === downPrice)
        }


        res.send({
            code:1,
            data: newList
        })
    })
}